using System;

namespace NAsserter.Impl
{
    public class PropertyArgumentExpression<TParent, TProp> : BaseChainedExpression<TParent>, IHideObjectMembers
    {
        private readonly string _propertyName;
        private readonly TProp _propertyValue;

        public PropertyArgumentExpression(IArgumentExpressions<TParent> parent, TProp propertyValue, string propertyName)
            : base(parent)
        {
            _propertyValue = propertyValue;
            _propertyName = propertyName;
        }

        public virtual IArgumentExpressions<TParent> Assertions(Action<IArgumentExpressions<TProp>> propertyAssertions)
        {
            propertyAssertions.Invoke(new ArgumentExpressionsImpl<TProp>(_propertyValue, Parent.Name, Parent.Name + "." + _propertyName));
            return Parent;
        }
    }

    public class NullPropertyArgumentExpression<TParent, TProp> : PropertyArgumentExpression<TParent, TProp>
    {
        public NullPropertyArgumentExpression(IArgumentExpressions<TParent> parent, TProp propertyValue, string propertyName) : base(parent, propertyValue, propertyName) { }

        public override IArgumentExpressions<TParent> Assertions(Action<IArgumentExpressions<TProp>> propertyAssertions)
        {
            return Parent;
        }
    }
}